<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.seculab.member.domain.Member" %>    
    
<%
	Cookie[] cookies = request.getCookies();
	String str ="";
	if(cookies != null) {
		for(int i = 0; i < cookies.length; i++) {
			if(cookies[i].getName().equals("seculab")) {
	  			str = cookies[i].getValue();
			}
		}
	}

	Member member = (Member)session.getAttribute("member");
%>    
    
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include file="../common/commonCssJs.jsp" %>
<script type="text/javascript">
	function login() {
		var re_id = /^[a-z0-9_-]{6,10}$/; // 아이디 검사식
		var re_pw = /^[a-z0-9_-]{6,10}$/; // 비밀번호 검사식
		var
			id = $('#id'),
			password = $('#password');
		
		if (re_id.test(id.val()) != true) { 
			alert('[ID 입력 오류] 유효한 ID를 입력해 주세요.');
			id.focus();
			return false;
		} else if(re_pw.test(password.val()) != true) { 
			alert('[PW 입력 오류] 유효한 PW를 입력해 주세요.');
			password.focus();
			return false;
		}	
	}
</script>
</head>
<body>

<div id="wapper">
	<header>
	<%@ include file="../common/layout/header.jsp"%>
	</header>
	
	<nav>
	<%@ include file="../common/layout/nav.jsp"%>
	</nav>
	
	<aside>
	<%@ include file="../common/layout/aside.jsp"%>
	</aside>
	
	<section>
		
		<% if(member == null) { %>
		<form action="/admin/app/login/login" method="POST" onsubmit="return login();">
		<input type="hidden" id="remId" value="<%=str%>"/ >
		<table>
			<tr>
				<td>아이디</td>
				<td><input type="text" id="id" name="id" size="10" /></td>
				<td><input type="checkbox" id="id_save" name="id_save" value="Y" /> ID저장</td>
			</tr>
			<tr>
				<td>비밀번호</td>
				<td><input type="password" id="password" name="password" size="10" /> </td>
				<td><input type="submit" value="로그인" /> </td>
			</tr>
			<tr>
				<td><a href="/admin/app/member/regiMember">회원가입</a></td>
				<td colspan="2">아이디/비밀번호찾기</td>
			</tr>
		</table>
		</form>
		<% } else { %>
		content
		<% } %>
		
	</section>
	
	<footer>
	<%@ include file="../common/layout/footer.jsp"%>
	</footer>
</div>
	
<script type="text/javascript">
	$("#id").focus();
	
	if($("#remId").val().length != 0) {
     	$("#id").attr("value", $("#remId").val());
     	$("#id_save").attr("checked", true);
     	$("#id_save").attr("value", "Y");
	} else {
		$("#id_save").attr("checked", false);
		$("#id_save").attr("value", "N");
	}		
	
	$("#id_save").change(function() {
		if($(this).is(":checked")) {
			$(this).attr("checked", "checked");	
			$(this).attr("value", "Y");
		} else {
			$(this).attr("checked", null);
			$(this).attr("value", "N");
		}
	});
</script>
</body>
</html>